-- This script demonstrates using AppleScript with MacHTTP to generate -- dynamic World Wide Web documents. -- -- MacHTTP will only read and execute scripts that have been saved as -- text only. Once the script is loaded by MacHTTP, it is passed to the default -- scripting system (usually AppleScript) for your server for execution. -- MacHTTP prepends the script's source code with a line that is the equivalent of: -- set http_request to "" -- where is the actual data received from the WWW client. -- -- The result of the script execution is then returned to the client as a HTML -- document. The following script shows how to turn AppleScript results into HTML. set crlf to (ASCII character 13) & (ASCII character 10) set http_10_header to "HTTP/1.0 200 OK" & crlf & "Server: MacHTTP" & crlf & Â "MIME-Version: 1.0" & crlf & "Content-type: text/html" & crlf & crlf set file_path to ":" -- if this script is in a subdirectory below MacHTTP, change this to the proper relative path -- Create the title for the HTML document set header to http_10_header & "Script Test One

This is a test:

" -- Add some text to the body of the document set body to "This is a test of special chars. See \"Spot\" run! Here's a backslash -> \\" -- Show the current time on the server set body to body & "

The time is:

" & (current date) -- The following shows how to reference the args passed in from MacHTTP set args to "

Arguments passed in:

" & http_request set search_args to "

Search arguments:

" & http_search_args -- Show all the files in the folder "file_path" and turn HTML files into anchors set filelist to "

Files on the server:

" -- send it all back to the server for transmission to the client return header & body & args & search_args & filelist